home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
MISCEOUS
/
BEALE2.LZH
/
BEALE2.C
< prev
next >
Wrap
Text File
|
1986-02-18
|
1KB
|
85 lines
/* beale2.c
*
* a "C" program that decrypts the second Beale cipher,
* by R.E.Sawyer, 3620 Spencer St. 30, Torrance, CA, 90503.
*
* Modified by:
* Ranny Fullinwider, 15922 Haven Hills, Houston, Tx. 77084
* 02/17/86
*/
#include <stdio.h>
FILE *fopen(), *kfil, *cfil;
char *keyfile, *cyfile;
int cipher[764];
char key[1323];
main(argc,argv)
int argc;
char *argv[];
{
int i, j, k;
if (argc != 3) {
printf("\nUsage: beale2 b2 b0");
printf("\n\n (for fun, b2 and b0 may be replaced with other files)\n");
exit(0);
}
printf("\nReading files ...\n\n");
read_cipher(argv[1]);
read_key(argv[2]);
printf("Plaintext:\n\n");
i = 0;
j = 0;
while ((k = cipher[i++]) != '\0') {
printf("%c", tolower(key[k-1]));
if(j == 40) {
printf("\n");
j=0;
}
else
j++;
}
printf("\n");
exit(0);
}
read_cipher(cypfile)
char cypfile[];
{
int i;
char *buf;
if ((cfil = fopen(cypfile, "r")) == NULL)
{
printf("\nCan't open %s",cypfile);
exit();
}
i = 0;
while (fgets(buf, 80, cfil))
sscanf(buf, "%d", &cipher[i++]);
cipher[i] = '\0';
fclose(cfil);
}
read_key(keyfile)
char keyfile[];
{
int i;
char *buf;
if ((kfil = fopen(keyfile, "r")) == NULL)
{
printf("\nCan't open %s", keyfile);
exit();
}
i = 0;
while (fgets(buf, 80, kfil))
sscanf(buf, "%c", &key[i++]);
key[i] = '\0';
fclose(kfil);
}